


class Soultion:
    def __init__(self):
        pass

    def get_target(self,num,target):
        num = sorted(num)
        sum_target = num[0] + num[1] + num[2]
        for i in num:
            start,end = i+1,len(num)-1
            while start< end:
                tmp = num[start] + num[i] + num[end]
                if abs(tmp-target) < abs(sum_target-target):
                    sum_target =tmp
                if sum_target > target:
                    end -= 1
                elif sum_target < target:
                    start += 1
                else:
                    return sum_target

        return sum_target

if __name__ == '__main__':
    S = Soultion()
    print(S.get_target([4,5,7,8,6],14))
